<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
        <div>这是div</div>
        <input type="text" id="i1">
        <input type="button" value="按钮" onclick="f()">

        <script>
            function f() {
                /*得到文本框和div*/
                let i = document.querySelector("#i1")
                let d = document.querySelector("div")
                d.innerText = i.value;
            }
        </script>

    </body>
</html>